<template>
  <div>
    <myheader></myheader>
    <navtable></navtable>
    <b class="line"></b>
    <div class="clear"></div>
    <div class="center">
      <div class="col-main">
        <div class="main-wrap">
          <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">账单明细</strong> / <small>Electronic&nbsp;bill</small></div>
          </div>
          <hr>

          <!--交易时间	-->

          <div class="order-time">
            <div class="mb-10">
              <span>选择起止日期：</span>
              <el-date-picker v-model="startTime" @change="qryPayOrders()" type="date" placeholder="选择开始时间">
              </el-date-picker>
              -
              <el-date-picker v-model="endTime" @change="qryPayOrders()" type="date" placeholder="选择结束时间">
              </el-date-picker>
            </div>
            <div class="clear"></div>
          </div>

          <div style="padding:10px">
            <el-table :data="payOrders" height="400px" style="width: 100%">
              <el-table-column label="日期" width="180">
                <template slot-scope="scope">
                  <em v-text="dateFormatter(scope.row.createTime)"></em>
                </template>
              </el-table-column>
              <el-table-column label="付款方式" width="180">
                <template slot-scope="scope">
                  <em v-text="payTypeFormatter(scope.row.payType)"></em>
                </template>
              </el-table-column>
              <el-table-column prop="id" label="支付单Id" width="180">
              </el-table-column>
              <el-table-column label="金额" width="100">
                <template slot-scope="scope">
                  <em v-text="scope.row.payPrice+scope.row.balance"></em>
                </template>
              </el-table-column>
              <el-table-column prop="name" label="账单类型" width="100">
                <template slot-scope="scope">
                  <em v-if="scope.row.type == 0">支出</em>
                  <em v-if="scope.row.type == 1">收入</em>
                </template>
              </el-table-column>
              <el-table-column prop="name" label="状态" width="100">
                <template slot-scope="scope">
                  <em v-if="scope.row.payStatus == 0">待支付</em>
                  <em v-if="scope.row.payStatus == 1">已支付</em>
                  <em v-if="scope.row.payStatus == 2">已取消</em>
                </template>
              </el-table-column>
              <el-table-column prop="comment" label="账单说明">
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--底部-->
        <foot></foot>
      </div>

      <leftmenu></leftmenu>
    </div>
    <navfull></navfull>
  </div>
</template>

<script>
import myheader from '@/components/myheader.vue'
import navfull from '@/components/navfull.vue'
import navtable from '@/components/navtable.vue'
import leftmenu from '@/components/leftmenu.vue'
import foot from '@/components/foot.vue'
export default {
  name: 'bills',
  data () {
    return {
      startTime: null,
      endTime: null,
      type: -1,
      payOrders: []
    }
  },
  components: {
    myheader,
    navfull,
    navtable,
    leftmenu,
    foot
  },
  mounted () {
    this.endTime = new Date();
    var date = new Date();
    date.setDate(1);
    this.startTime = date;
    this.qryPayOrders();
  },
  methods: {
    qryPayOrders () {
      this.axios.get("/trade/pay/payOrders", {
        params: {
          startTimeStr: this.startTime.getTime(),
          endTimeStr: this.endTime.getTime(),
          type: this.$route.query.type
        }

      }).then((res) => {
        var result = res.data;
        if (result.code == 200) {
          this.payOrders = result.data;
        }
      })
    },
    dateFormatter (date) {
      var time = new Date(date);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
    },
    payTypeFormatter (type) {
      switch (type) {
        case 1:
          return "支付宝"
        case 2:
          return "余额"
        case 3:
          return "混合支付"
        case 6:
          return "系统支付"
      }
    }
  }
}
function add0 (m) {
  return m < 10 ? '0' + m : m
}
</script>

<style scoped>
@import "../../../AmazeUI-2.4.2/assets/css/admin.css";
@import "../../../AmazeUI-2.4.2/assets/css/amazeui.css";
@import "../../../assets/css/personal.css";
@import "../../../assets/css/bilstyle.css";
</style>

